{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="t-a-wait-con">
    <div class="tablesWrap"> 
    	<div class="tables-searchbox">
            <div class="t-a-wait-top">
                <form action="" method="post" id="rank_waiting">
                    
                <!--<div class="t-a-wait-top-li"><span>昵称：</span><input type="text" placeholder="" value="{$nickname}" class="mini" name="nickname"> </div>-->
				<div class="t-a-wait-top-li"><span>标题：</span><input type="text" placeholder="" value="{$title}" class="mini" name="title"> </div>
                <div class="t-a-wait-top-li" style="width:400px;">
                    <div class="formitems inline">  
                        <label class="fi-name" style="width:70px; font-weight:normal;">发布时间：</label>  
                        <div class="form-controls" style="margin-left:80px;">  
				            <input type="text" style="width:120px;" autocomplete="off" class="Wdate" name="start_time" value="{if $start_time}{date('Y-m-d',$start_time)}{/if}" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd'})">  

                            <span class="fi-text">-</span>  
                            
                            <input type="text" style="width:120px;" autocomplete="off" class="Wdate" name="end_time" value="{if $end_time}{date('Y-m-d',$end_time)}{/if}" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd'})">  
                        </div>  
                    </div> 
                </div>

                <div class="t-a-wait-top-li" style=""><input type="hidden" name="submit" value="search" /><button class="btn"><i class="gicon-search"></i>搜索</button> </div>
              </form>
            </div>        
        </div> 
        <table class="wxtables">  
            <colgroup>  
            <col width="5%"> 
            <!--<col width="7%">  -->
            <col width="15%">  
            <col width="7%">
            <col width="7%">  
            <col width="7%">  
            <col width="20%">
            </colgroup>  
            <thead>  
                <tr>  
                    <td>选择</td>   
                    <!--<td>昵称</td>  -->
                    <td>标题</td>
                    <td>发布时间</td>
                    <td>收藏数</td>
                    <td>观点数</td>
                    <td>操作</td>  
                </tr>  
            </thead>  
            <tbody>
				{foreach from=$topic_list item=v}
                <tr>  
                    <td><input type="checkbox" class="checkbox" value='{$v.topic_id}' name="a[]"></td> 
                    <!--<td>{$v.nickname}</td>  -->
                    <td>{$v.title}</td>
                    <td>{$v.addtime}</td>
                    <td>{$v.collect_num}</td>
                    <td>{$v.view_num}</td>
                    <td>  
                     	<a href="/AcpTopic/edit_topic/topic_id/{$v.topic_id}"  class="btn" title="修改">修改</a>
                     	<a href="/AcpTopic/get_view_list/topic_id/{$v.topic_id}"  class="btn" title="查看观点">查看观点</a> 
                        <a href="javascript:;" onclick="delTopic({$v.topic_id});" class="btn" title="删除"><i class="gicon-trash black"></i>删除</a>  
                    </td>  
                </tr>
                {foreachelse}
					<tr><td colspan="11">没有符合条件的记录</td></tr>
                {/foreach}
            </tbody>  
        </table>  
        <!-- end wxtables -->  
        <div class="tables-btmctrl clearfix">  
            <div class="fl">  
				<a href="javascript:;" class="btn btn-blue" onclick="Select()">全选</a>  
				<a href="javascript:;" class="btn btn-blue" onclick="Cancel()">取消</a>  
				<a href="javascript:;" class="btn btn-blue" onclick="batch_delTopic()">删除</a>  
            </div>
            <div class="fr">  
                <div class="paginate">  
                    {$show}
                </div>  
                <!-- end paginate -->  
            </div>  
        </div>  
        <!-- end tables-btmctrl -->  
    </div>  
    <!-- end tablesWrap --> 
</div>
{/block} 

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script>
    var url = '{$url}';
{literal}
//全选
function Select(){
	var sel=document.getElementsByName("a[]");
	for(var i=0;i<sel.length;i++){
		sel[i].checked=true;
	}
}
//取消全选
function Cancel(){
	var sel=document.getElementsByName("a[]");
	for(var i=0;i<sel.length;i++){
		sel[i].checked=false;
	}
}


function delTopic(_ids){
	$.jPops.confirm({
		title:"提示",
		content:'您确定要删除这条数据吗？',
		okBtnTxt:"确定",
		cancelBtnTxt:"取消",
		callback:function(r){
			if(r){
				$.ajax({
					url: '/AcpTopic/del_topic',
					data: {ids: _ids},
					type:'post',
					success: function(data){
                        
						if(data == 'success'){
                            alert('删除成功');
                            location.reload();
                        } else {
                            alert('删除失败');
                        }
					}
				});
			}
			return true;
		}
	});
}

function batch_delTopic()
{
	
	$.jPops.confirm(
	{  
		 title:"提示",  
		 content:"您确定要执行这些操作吗？",  
		 okBtnTxt:"确定",  
		 cancelBtnTxt:"取消",  
		 callback:function(r)
		 {  
			 if(r)
			 {
				 var ids = '';
				 var count = 0;
				 $('input[name="a[]"]:checked').each(function(){
					 count ++;
					 ids += $(this).val() + ',';
				 });

				 if (!count)
				 {
					 alert('对不起，请选择至少一项进行操作！');
					 return;
				 }

				 ids = ids.substr(0, ids.length - 1);

				 $.post('/AcpTopic/del_topic', {"ids":ids}, function(data, textStatus) 
				 {
					if (data == 'success')
					{
						alert('恭喜您，删除成功！');
						location.reload();
					}
					else
					{
						alert('对不起，删除失败');
					}
				});
			 }  
			 return true;  
		 }
	 });
}
</script>
{/literal} 
{/block} 

{block name="css"}
<link rel="stylesheet" href="/Public/Css/acp/AcpUser/audit_waiting.css" type="text/css" />
{/block}
